package com.onepower.admin.controller;


import com.onepower.core.modules.repository.entity.MatchScheduleLocked;
import com.onepower.core.modules.service.IMatchScheduleLockedService;
import com.onepower.core.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author kin
 * @since 2018-08-12
 */
@RestController
@RequestMapping("/api/match/scheduleLocked")
public class MatchScheduleLockedController {

    @Autowired
    private IMatchScheduleLockedService matchScheduleLockedService;

    @PostMapping(value = "lock")
    public CommonResult lock(@RequestBody MatchScheduleLocked locked) {
        matchScheduleLockedService.lockMatchSchedule(locked);
        return new CommonResult();
    }

    @PostMapping(value = "unLocked")
    public CommonResult unLocked(@RequestBody Integer[] lockIds) {
        matchScheduleLockedService.removeByIds(Arrays.asList(lockIds));
        return new CommonResult();
    }

    @PostMapping(value = "lockNextSchedule")
    public CommonResult lockNextSchedule(@RequestParam int matchId,
                                         @RequestParam int matchAdminId) {
        matchScheduleLockedService.lockNextMatchSchedule(matchId, matchAdminId);
        return new CommonResult();
    }
}
